package com.huizu.common.core.domain.entity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.*;

import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.huizu.common.annotation.Excel;
import com.huizu.common.annotation.Excel.ColumnType;
import com.huizu.common.annotation.Excel.Type;
import com.huizu.common.annotation.Excels;
import com.huizu.common.core.domain.BaseEntity;
import com.huizu.common.xss.Xss;

/**
 * 用户对象 sys_user
 * 
 * @author ruoyi
 */
@Data
public class SysUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号", type = Type.EXPORT)
    private Long userId;

    /**
     * 学校同步id
     */
    private String universityId;

    /** 部门ID */
    @Excel(name = "部门编号", type = Type.EXPORT)
    private Long deptId;

    /** 用户账号 */
    @Excel(name = "登录名称", type = Type.EXPORT)
    private String userName;

    /** 用户昵称 */
    @Excel(name = "教师姓名")
    private String nickName;

    /** 用户邮箱 */
    @Excel(name = "用户邮箱")
    private String email;


    @Excel(name = "用户类型", type = Type.EXPORT)
    private String userType;

    /** 手机号码 */
    @Excel(name = "手机号码")
    private String phonenumber;

    /** 用户性别 */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /** 用户头像 */
    @Excel(name = "头像", type = Type.EXPORT)
    private String avatar;

    /** 密码 */
    private String password;

    /** 帐号状态（0正常 1停用） */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 最后登录IP */
    @Excel(name = "最后登录IP", type = Type.EXPORT)
    private String loginIp;

    /** 最后登录时间 */
    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /** 关联id */
    @Excel(name = "关联id", type = Type.EXPORT)
    private String busId;

    /** uniId */
    @Excel(name = "uniId", type = Type.EXPORT)
    private String uniId;

    /** openID */
    @Excel(name = "openID", type = Type.EXPORT)
    private String openId;

    /** openId2 */
    @Excel(name = "openId2", type = Type.EXPORT)
    private String openId2;

    /** 学号 */
    @Excel(name = "教工号")
    private String jsNumber;

    /** 手机号码映射 */
    private String phone;

    /** 学院ID */
    @Excel(name = "学院ID")
    private String xyId;

    /** 学校ID */
    @Excel(name = "学校ID", type = Type.EXPORT)
    private String xxId;


    /** 专业ID */
    @Excel(name = "专业ID", type = Type.EXPORT)
    private String zyId;

    /** 年级ID */
    @Excel(name = "年级ID", type = Type.EXPORT)
    private String njId;

    /** 班级ID */
    @Excel(name = "班级ID", type = Type.EXPORT)
    private String clId;

    /** 年龄 */
    @Excel(name = "年龄", type = Type.EXPORT)
    private Long age;

    /** 职位ID */
    @Excel(name = "职位ID")
    private String zwId;

    private String xyName;

    private String xxName;

    private String zwName;

    private String code;

    private String token;

    private String search;

    private String passwordNew;

    @Excel(name = "备注")
    private String remark;



    /** 部门对象 */
    @Excels({
        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
    })
    private SysDept dept;

    /** 角色对象 */
    private List<SysRole> roles;

    /** 角色组 */
    private Long[] roleIds;

    /** 岗位组 */
    private Long[] postIds;

    /** 角色ID */
    private Long roleId;

    private String[] authList;

    //进度

    private BigDecimal jcldJdPer;

    private BigDecimal ldzjJdPer;

    private BigDecimal ldgyJdPer;


    private BigDecimal ldcgJdPer;


    private int jcldJdCount;

    private int ldzjJdCount;

    private int ldgyJdCount;

    private int ldcgJdCount;

    private int jdCount;
    /**
     * 理论成绩进度
     */
    private BigDecimal llcjJdPer;



    @Xss(message = "用户昵称不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName()
    {
        return nickName;
    }

    public void setNickName(String nickName)
    {
        this.nickName = nickName;
    }

    @Xss(message = "用户账号不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName()
    {
        return userName;
    }


    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail()
    {
        return email;
    }



    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber()
    {
        return phonenumber;
    }


    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }


    @Excel(name = "小程序密码", type = Type.EXPORT)
    private String unPassword;

    private List<String> xyIds;


    public SysUser()
    {

    }

    public SysUser(Long userId)
    {
        this.userId = userId;
    }



}
